package com.yanqu.road.entity.activity.fivehero;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class FiveHeroUserData extends DataObject {

    private int activityId;

    private long userId;

    //声望
    private long integral;
    //campId,time领取时间
    private Map<Integer,Long> worshipTimeMap = new ConcurrentHashMap<>();

    private int currentMall;

    private Map<Integer, Long> mallMap = new ConcurrentHashMap<>();
    //触发礼包次数
    private Map<Integer,Integer> mallTimesMap = new ConcurrentHashMap<>();


    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }


    public long getIntegral() {
        return integral;
    }

    public void setIntegral(long integral) {
        if(integral != this.integral){
            this.integral = integral;
            setUpdateOption();
        }
    }

    public int getCurrentMall() {
        return currentMall;
    }

    public void setCurrentMall(int currentMall) {
        if(currentMall != this.currentMall){
            this.currentMall = currentMall;
            setUpdateOption();
        }
    }

    public Map<Integer, Long> getMallMap() {
        return mallMap;
    }

    public void setMallMap(Map<Integer, Long> mallMap) {
        this.mallMap = mallMap;
        setUpdateOption();
    }

    public Map<Integer, Integer> getMallTimesMap() {
        return mallTimesMap;
    }

    public void setMallTimesMap(Map<Integer, Integer> mallTimesMap) {
        this.mallTimesMap = mallTimesMap;
        setUpdateOption();
    }

    public void setMallTime(int mallId, long time){
        mallMap.put(mallId, time);
        setUpdateOption();
    }

    public int getMallTimes(int mallId){
        if(mallTimesMap.containsKey(mallId)){
            return mallTimesMap.get(mallId);
        }
        return 0;
    }

    public void addMallTimes(int mallId, int times){
        int totalTimes = getMallTimes(mallId);
        totalTimes += times;
        mallTimesMap.put(mallId, totalTimes);
        setUpdateOption();
    }

    public void clearMallTimes(int mallId){
        mallTimesMap.remove(mallId);
        setUpdateOption();
    }

    public void reduceMallTimes(int mallId, int times){
        int totalTimes = getMallTimes(mallId);
        totalTimes -= times;
        if(totalTimes < 0){
            totalTimes = 0;
        }
        mallTimesMap.put(mallId, totalTimes);
        setUpdateOption();
    }


    public void removeMall(int mallId){
        mallMap.remove(mallId);
        setUpdateOption();
    }

    public long getMallTime(int mallId){
        if(mallMap.containsKey(mallId)){
            return mallMap.get(mallId);
        }
        return 0;
    }

    public Map<Integer, Long> getWorshipTimeMap() {
        return worshipTimeMap;
    }

    public void setWorshipTimeMap(Map<Integer, Long> worshipTimeMap) {
        this.worshipTimeMap = worshipTimeMap;
        setUpdateOption();
    }
}
